package com.example.NeteaseCloudMusicApi.ui.adapter;

import android.content.Intent;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.recyclerview.widget.RecyclerView;

import com.example.NeteaseCloudMusicApi.R;
import com.example.NeteaseCloudMusicApi.entity.Found;
import com.example.NeteaseCloudMusicApi.entity.News;
import com.example.NeteaseCloudMusicApi.ui.activity.MainActivity;

import java.util.List;

import static androidx.constraintlayout.motion.utils.Oscillator.TAG;

public class FoundAdapter extends RecyclerView.Adapter<FoundAdapter.ViewHolder> {

    private List<Found> mFound;

    public static class ViewHolder extends RecyclerView.ViewHolder{
        ImageView image;
        TextView name;
        public ViewHolder (View view) {
            super(view);
            image = view.findViewById(R.id.found_circle_button_image);
            name = view.findViewById(R.id.found_circle_button_information);
        }
    }

    public FoundAdapter(List<Found> found){
        mFound = found;
        }
        @Override
        public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType){
            View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.fount_circle_button,parent,false);
            ViewHolder holder = new ViewHolder(view);
            return holder;
        }

        @Override
        public void onBindViewHolder(ViewHolder holder, int position){

            Found found = mFound.get(position);
            holder.image.setImageResource(found.getImageId());
            holder.name.setText(found.getName());


        }

        @Override
        public int getItemCount(){
            return mFound.size();
        }
}
